#!/usr/bin/python
# -- coding:utf8 --

import util_log as utils
import pandas as pd
import pymysql


import warnings

warnings.filterwarnings("ignore")


def select_sql_mysql(sql):
    """
    风控库获取数据
    :param sql:
    :return:
    """
    conn = pymysql.Connect(
        host='159.138.99.18',
        port=3306,
        user='root',
        passwd='Qiuliu123!@#',
        database='adms_core_ph'
    )
    df = pd.read_sql(sql, con=conn)
    conn.close()
    return df


def select_sql_mysql_v1(sql):
    """
    从业务库里面获取数据集
    :param sql:
    :return:
    """
    conn = pymysql.Connect(
        host='119.13.100.83',
        port=3306,
        user='readonly',
        passwd='Gyt@20231122',
        database='phdcdb'
    )
    df = pd.read_sql(sql, con=conn)
    conn.close()
    return df



def get_is_none(x):
    """
    #判断参数是否为空
    Parameters
    ----------
    x：参数

    Returns
    -------
    返回布尔值
    """
    if x is None or str(x).replace(' ', '').lower().strip() in ['-999999', '-999976', '-999977', '-999978',
                                                                '-999999.0', '-999976.0', '-999977.0', '-999978.0',
                                                                'none', 'nan', 'nat', '', '000000000000000']:
        return True
    else:
        return False


def get_is_match(parameter1, parameter2):
    """
    判断是否完全匹配
    Parameters
    ----------
    parameter1：参数1
    parameter2：参数2

    Returns
    -------
    返回布尔值（1或者0）
    """
    try:
        if parameter1 == parameter2:
            return 1
        else:
            return 0
    except Exception as e:
        utils.get_logger().error(e)
        return -9976
